package com.itheima.homework;
import com.itheima.homework.Square;

import java.util.Scanner;

public class Test06 {
    public static void main(String[] args) {
        //用户提示
        System.out.println("请选择您要计算的图形");
        System.out.println("1.正方形   2.长方形   3.圆形");
        int choice = new Scanner(System.in).nextInt();
        switch(choice){
            case 1:
                System.out.println("请输入正方形的边长");
                double side = new Scanner(System.in).nextDouble();
                Square sq = new Square(side);
                System.out.println("周长:"+sq.getPerimeter());
                System.out.println("面积:"+sq.getArea());
                break;
            case 2:
                System.out.println("请输入长方形的长");
                double height = new Scanner(System.in).nextDouble();
                System.out.println("请输入长方形的宽");
                double width = new Scanner(System.in).nextDouble();
                Cfx cfx1 = new Cfx(height,width);
                System.out.println("周长:"+cfx1.getPerimeter());
                System.out.println("面积:"+cfx1.getArea());
                break;
            case 3:
                System.out.println("请输入圆形的半径");
                double r = new Scanner(System.in).nextDouble();
                Yuan yx = new Yuan(r);
                System.out.println("周长:"+yx.getPerimeter());
                System.out.println("面积:"+yx.getArea());
                break;
                default:
                System.out.println("输入有误");
        }





    }


}
class Cfx{
    private double height;
    private double width;

    public Cfx() {
    }

    public Cfx(double height, double width) {
        this.height = height;
        this.width = width;
        }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getPerimeter(){
        double perimeter = (this.height+this.width)*2;
        return perimeter;
    }

    public double getArea(){
        double area = this.height*this.width;
        return area;
    }

}

class Yuan{
    private double r ;
    private double pai = 3.14;

    public Yuan() {
    }

    public Yuan(double r) {
        this.r = r;
    }

    public double getR() {
        return r;
    }

    public void setR(double r) {
        this.r = r;
    }

    public double getPerimeter(){
        double perimeter = 2*this.pai*this.r;
        return perimeter;
    }

    public double getArea(){
        double area = this.pai*this.r*this.r;
        return area;
    }
}